package com.yj.suncity.user;

import org.json.JSONObject;

import com.yj.suncity.R;
import com.yj.suncity.async.AsyncTaskUtil;
import com.yj.suncity.async.AsyncTaskUtil.ResultCallBack;
import com.yj.suncity.constant.URLCon;
import com.yj.suncity.user.bean.AlreadyAdvBean;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

public class AlreadyPublishAdvActivity extends Activity {
	private Context context;
	private String userId;
	private String titleName;
	private TextView mTxt_all_price, mTxt_every_price, mTxt_share_price;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_already_advertse);
		context = this;
		userId = getIntent().getStringExtra("userid");
		titleName = getIntent().getStringExtra("titlename");
		findView();
		initData();
	}

	private void findView() {
		((TextView) findViewById(R.id.txt_title_name)).setText(titleName);
		mTxt_all_price = (TextView) findViewById(R.id.txt_all_price);
		mTxt_every_price = (TextView) findViewById(R.id.txt_every_price);
		mTxt_share_price = (TextView) findViewById(R.id.txt_share_price);
	}

	private void initData() {
		String path = URLCon.广告 + "?action=seeentadv&userid=" + userId;
		Log.d("", path);
		AsyncTaskUtil asyncTaskUtil = new AsyncTaskUtil(context, null, null,
				false, null, true, "正在加载......", new ResultCallBack() {
					@Override
					public void JSONResult(JSONObject jsonObject) {
						AlreadyAdvBean advBean = new AlreadyAdvBean(jsonObject);
						mTxt_all_price.setText(advBean.getSrplus_num());
						mTxt_every_price.setText(advBean.getAmount());
						mTxt_share_price.setText(advBean.getNum());
					}
				});
		asyncTaskUtil.execute(path);
	}

	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.btnHeadBack:
			this.finish();
			break;

		default:
			break;
		}
	}

}
